uint8_t lastc, nextc;

SetUpButtons()
{
   PORTC = 255U;   // Set port c as pull ups
   DDRC = 0;       // Set port c as all inputs

   lastc = (~(PINC) & 0x3FU); 
}

EndButtons()
{
	lastc = nextc;
}

uint8_t UpArrowButton()
{
	nextc = (~(PINC) & 0x3FU); 
	uint8_t returnVal = 0;
   if (nextc & (1<<2) & ~(lastc & (1<<2)))
   {
      returnVal = 1;
	}
		
	return(returnVal);
}

uint8_t DownArrowButton()
{
	nextc = (~(PINC) & 0x3FU); 
	uint8_t returnVal = 0;
	if (nextc & (1<<3) & ~(lastc & (1<<3)))
   {
      returnVal = 1;
	}
		
	return(returnVal);
}

uint8_t LeftArrowButton()
{
	nextc = (~(PINC) & 0x3FU); 
	uint8_t returnVal = 0;
	if (nextc & (1<<4) & ~(lastc & (1<<4)))
   {
      returnVal = 1;
	}
		
	return(returnVal);
}

uint8_t RightArrowButton()
{
	nextc = (~(PINC) & 0x3FU); 
	uint8_t returnVal = 0;
	if (nextc & (1<<5) & ~(lastc & (1<<5)))
   {
      returnVal = 1;
	}
		
	return(returnVal);
}

uint8_t LeftCircleButton()
{
	nextc = (~(PINC) & 0x3FU); 
	uint8_t returnVal = 0;
	if (nextc & (1<<0) & ~(lastc & (1<<0)))
   {
      returnVal = 1;
	}
		
	return(returnVal);
}

uint8_t RightCircleButton()
{
	nextc = (~(PINC) & 0x3FU); 
	uint8_t returnVal = 0;
	if (nextc & (1<<1) & ~(lastc & (1<<1)))
   {
      returnVal = 1;
	}
		
	return(returnVal);
}
